<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

// 授权登录

Route::group(['prefix' => 'auth'], function ($router) {
    $router->post('login', [\App\Http\Controllers\AuthController::class, 'login']);
    $router->post('network/auth', [\App\Http\Controllers\AuthController::class, 'NetworkAuth']);
    $router->post('network/login', [\App\Http\Controllers\AuthController::class, 'NetworkAuthLogin']);
    $router->post('network/register', [\App\Http\Controllers\AuthController::class, 'NetworkRegister']);
    $router->post('user/login', [\App\Http\Controllers\AuthController::class, 'auth']);
    $router->post('user/douyin/login', [\App\Http\Controllers\AuthController::class, 'douyinAuth']);
    $router->group(['middleware' => 'auth:api'], function ($router) {
        $router->post('logout', [\App\Http\Controllers\AuthController::class, 'logout']);
        $router->post('refresh', [\App\Http\Controllers\AuthController::class, 'refresh']);
        $router->post('me', [\App\Http\Controllers\AuthController::class, 'me']);
        $router->post('change/pwd', [\App\Http\Controllers\AuthController::class, 'changePwd']);
        $router->post('home', [\App\Http\Controllers\IndexController::class, 'home']);
        //修改头像
        $router->post('upd/me', [\App\Http\Controllers\AuthController::class, 'upd_me']);
    });
});

Route::group(['prefix' => 'home'], function ($router) {
    //轮播图列表
    $router->post('banner/listing', [\App\Http\Controllers\Client\IndexController::class, 'BannerListing']);
    //商品列表
    $router->post('goods/listing', [\App\Http\Controllers\Client\IndexController::class, 'GoodsListing']);
    //轮播图详情
    $router->post('banner/detail', [\App\Http\Controllers\Client\IndexController::class, 'BannerDetail']);
    //公告详情
    $router->post('notice/detail', [\App\Http\Controllers\Client\IndexController::class, 'NoticeDetail']);
    //根据经纬度 获取商家
    $router->post('map/network', [\App\Http\Controllers\Client\IndexController::class, 'MapNetwork']);
});


Route::group(['prefix' => 'goods'], function ($router) {
    //商品详情
    $router->post('detail', [\App\Http\Controllers\Client\GoodsController::class, 'GoodsDetail']);
    //商品下单详情
    $router->post('order/dettail', [\App\Http\Controllers\Client\GoodsController::class, 'OrderDetail']);
    //商品订单列表
    $router->post('order/listing', [\App\Http\Controllers\Client\GoodsController::class, 'OrderListing']);
    //商品订单详情
    $router->post('order/details', [\App\Http\Controllers\Client\GoodsController::class, 'OrderDetails']);
    //商品订单确认收货
    $router->post('order/confirm', [\App\Http\Controllers\Client\GoodsController::class, 'OrderConfirm']);
    //商品订单删除
    $router->post('order/delete', [\App\Http\Controllers\Client\GoodsController::class, 'OrderDelete']);
    //商品评论
    $router->post('order/content/add', [\App\Http\Controllers\Client\GoodsController::class, 'OrderContentAdd']);
    //商品订单评论
    $router->post('order/content', [\App\Http\Controllers\Client\GoodsController::class, 'OrderContent']);
    //评论列表
    $router->post('content/list', [\App\Http\Controllers\Client\GoodsController::class, 'ContentList']);
    //加入购物车
    $router->post('shopping/cart/add', [\App\Http\Controllers\Client\ShoppingCartController::class, 'Add']);
    //购物车列表
    $router->post('shopping/cart/list', [\App\Http\Controllers\Client\ShoppingCartController::class, 'ShoppingList']);
    //删除购物车
    $router->post('shopping/cart/del', [\App\Http\Controllers\Client\ShoppingCartController::class, 'Del']);
     //删除购物车
    $router->post('shopping/cart/count', [\App\Http\Controllers\Client\ShoppingCartController::class, 'Count']);
    //商品分类
    $router->post('type/list', [\App\Http\Controllers\Client\GoodsController::class, 'TypeList']);
});

Route::group(['prefix' => 'common'], function ($router) {
    //图片上传
    $router->post('oss/img/upload', [\App\Http\Controllers\Api\CommonController::class, 'OssUpload']);
});


Route::group([ 'prefix' => 'user',], function ($router) {
    //修改用户头像
    $router->post('update/user', [\App\Http\Controllers\Client\UserController::class, 'UpdateUser']);
    //添加/编辑
    $router->post('address/add', [\App\Http\Controllers\Client\UserController::class, 'UserAddressAdd']);
    //列表
    $router->post('address/listing', [\App\Http\Controllers\Client\UserController::class, 'UserAddressListing']);
    //删除
    $router->post('address/del', [\App\Http\Controllers\Client\UserController::class, 'UserAddressDel']);
    //详情
    $router->post('address/detail', [\App\Http\Controllers\Client\UserController::class, 'UserAddressDetail']);
    //我的
    $router->post('my', [\App\Http\Controllers\Client\UserController::class, 'My']);
    //分享小程序码
    $router->post('share/qrcode', [\App\Http\Controllers\Client\UserController::class, 'ShareQrcode']);
    //推广积分
    $router->post('share/wallet', [\App\Http\Controllers\Client\UserController::class, 'ShareWallet']);
    //积分明细
    $router->post('wallet/record', [\App\Http\Controllers\Client\UserController::class, 'WalletRecord']);
    //提现
    $router->post('wallet/withdrawal', [\App\Http\Controllers\Client\UserController::class, 'WalletWithdrawal']);
    //提现规则
    $router->post('withdrawal/rule', [\App\Http\Controllers\Client\UserController::class, 'WalletRule']);

});
/**
 * 积分兑换
 */
Route::group([ 'prefix' => 'integral',], function ($router) {
    //代金券列表
    $router->post('coupon/listing', [\App\Http\Controllers\Client\IntegralController::class, 'CouponListing']);
    //商品列表
    $router->post('goods/listing', [\App\Http\Controllers\Client\IntegralController::class, 'GoodsListing']);
    //商品分类
    $router->post('goods/type/listing', [\App\Http\Controllers\Client\IntegralController::class, 'GoodsTypeListing']);
    //商品详情
    $router->post('goods/detail', [\App\Http\Controllers\Client\IntegralController::class, 'GoodsDetail']);
    //兑换优惠券
    $router->post('coupon/exchange', [\App\Http\Controllers\Client\IntegralController::class, 'CouponExchange']);
    //兑换商品
    $router->post('goods/exchange', [\App\Http\Controllers\Client\IntegralController::class, 'GoodsExchange']);
    //兑换记录
    $router->post('exchange/listing', [\App\Http\Controllers\Client\IntegralController::class, 'ExchangeListing']);
    //确认收货
    $router->post('order/confirm', [\App\Http\Controllers\Client\IntegralController::class, 'OrderConfirm']);
});

Route::group([ 'prefix' => 'merchant'], function ($router) {
    //商户列表
    $router->post('merchant/listing', [\App\Http\Controllers\Client\MerchantController::class, 'MerchantListing']);
    //网点区域划分提交
    $router->any('/admin_points', [\App\Http\Controllers\Client\MerchantController::class, 'admin_points']);
    //网点区域划分删除
    $router->any('/admin_points/del', [\App\Http\Controllers\Client\MerchantController::class, 'admin_points_delete']);
    //已规划的网点数据
    $router->any('/admin_points/listing', [\App\Http\Controllers\Client\MerchantController::class, 'admin_points_listing']);
    //网点区域划分提交
    $router->any('/region/add', [\App\Http\Controllers\Client\RegionController::class, 'region_add']);
    //网点区域划分删除
    $router->any('/region/del', [\App\Http\Controllers\Client\RegionController::class, 'region_del']);
    //已规划的区域数据
    $router->any('/region/listing', [\App\Http\Controllers\Client\RegionController::class, 'region_listing']);

});

Route::group([ 'prefix' => 'coupon'], function ($router) {
    //新人大礼包
    $router->post('package/listing', [\App\Http\Controllers\Client\CouponController::class, 'PackageListing']);
    //优惠券列表
    $router->post('coupon/listing', [\App\Http\Controllers\Client\CouponController::class, 'CouponListing']);
    //领取优惠券
    $router->post('coupon/receive', [\App\Http\Controllers\Client\CouponController::class, 'CouponReceive']);
    //我的优惠券列表
    $router->post('my/listing', [\App\Http\Controllers\Client\CouponController::class, 'MyListing']);
});

Route::group([ 'prefix' => 'water_ticket'], function ($router) {
    //水票列表
    $router->post('water_ticket/listing', [\App\Http\Controllers\Client\WaterTicketController::class, 'WaterTicketListing']);
    //水票详情
    $router->post('water_ticket/detail', [\App\Http\Controllers\Client\WaterTicketController::class, 'WaterTicketDetail']);
    //我的水票列表
    $router->post('my/listing', [\App\Http\Controllers\Client\WaterTicketController::class, 'MyWaterTicketListing']);
    //水票明细
    $router->post('my/record', [\App\Http\Controllers\Client\WaterTicketController::class, 'MyWaterTicketRecord']);
    //转让
    $router->post('transfer', [\App\Http\Controllers\Client\WaterTicketController::class, 'WaterTicketTransfer']);

});

Route::group([ 'prefix' => 'order'], function ($router) {
    //下单购买水票
    $router->post('water_ticket/order/pay', [\App\Http\Controllers\Client\PayOrderController::class, 'WaterTicketPayOrder']);
    //水票下单回调
    $router->any('water_ticket/notify_url', [\App\Http\Controllers\Client\PayOrderController::class, 'WaterTicketNotifyUrl']);
    //商品下单
    $router->any('goods/place', [\App\Http\Controllers\Client\PayOrderController::class, 'GoodsPlace']);
    //商品订单微信小程序支付
    $router->any('goods/pay', [\App\Http\Controllers\Client\PayOrderController::class, 'GoodsPay']);
    //商品订单支付宝APP支付
    $router->any('goods/alipay/pay', [\App\Http\Controllers\Client\PayOrderController::class, 'GoodsAlipayPay']);
    //商品下单回调
    $router->any('goods/notify_url', [\App\Http\Controllers\Client\PayOrderController::class, 'GoodsNotifyUrl']);
    //商品订单支付宝APP支付
    $router->any('goods/douyin/notify_url', [\App\Http\Controllers\Client\PayOrderController::class, 'GoodsDouyinPay']);
});

Route::group([ 'prefix' => 'exchangeable'], function ($router) {
    //添加易换
    $router->post('add', [\App\Http\Controllers\Client\ExchangeableController::class, 'add']);
    //易换列表
    $router->post('listing', [\App\Http\Controllers\Client\ExchangeableController::class, 'listing']);
});

Route::group([ 'prefix' => 'activity',], function ($router) {
    //活动列表
    $router->post('listing', [\App\Http\Controllers\Client\ActivityController::class, 'listing']);
    //活动详情
    $router->post('detail', [\App\Http\Controllers\Client\ActivityController::class, 'detail']);
});

Route::group([ 'prefix' => 'setup'], function ($router) {
    //意见反馈
    $router->post('feedback/add', [\App\Http\Controllers\Client\SetupController::class, 'FeedbackAdd']);
    //关于我们
    $router->post('about/us', [\App\Http\Controllers\Client\SetupController::class, 'AboutUs']);
    //服务协议
    $router->post('service/agreement', [\App\Http\Controllers\Client\SetupController::class, 'ServiceAgreement']);
});

/****************************************************************商户端******************************************************************/
Route::group([ 'prefix' => 'network'], function ($router) {
    //商户端订单
    $router->post('order/listing', [\App\Http\Controllers\Network\OrderController::class, 'OrderListing']);
    //订单详情
    $router->post('order/details', [\App\Http\Controllers\Network\OrderController::class, 'OrderDetails']);
    //订单接单
    $router->post('order/receiving', [\App\Http\Controllers\Network\OrderController::class, 'OrderReceiving']);
    //订单送达
    $router->post('order/service', [\App\Http\Controllers\Network\OrderController::class, 'OrderService']);
    //商铺详情
    $router->post('shop/details', [\App\Http\Controllers\Network\ShopController::class, 'ShopDetails']);
    //店铺设置
    $router->post('shop/setup', [\App\Http\Controllers\Network\ShopController::class, 'ShopSetup']);
    //店铺设置
    $router->post('shop/my', [\App\Http\Controllers\Network\ShopController::class, 'ShopMy']);
    //商品列表
    $router->post('goods/listing', [\App\Http\Controllers\Network\GoodsController::class, 'GoodsListing']);
    //统计
    $router->post('statistics', [\App\Http\Controllers\Network\ShopController::class, 'Statistics']);
    //上货商品列表
    $router->post('loading/goods/listing', [\App\Http\Controllers\Network\GoodsController::class, 'LoadingGoodsListing']);
    //上货
    $router->post('loading/goods/add', [\App\Http\Controllers\Network\GoodsController::class, 'LoadingGoodsAdd']);
    //上货订单详情
    $router->post('loading/order/detail', [\App\Http\Controllers\Network\GoodsController::class, 'LoadingOrderDetail']);
    //下单支付
    $router->post('loading/order/pay', [\App\Http\Controllers\Network\GoodsController::class, 'LoadingOrderPay']);
    //下单支付回调
    $router->any('loading/order/notify', [\App\Http\Controllers\Network\GoodsController::class, 'LoadingOrderNotify']);
    //商品信用列表
    $router->post('credit/goods/detail', [\App\Http\Controllers\Network\CreditController::class, 'GoodsDetail']);
    //商品信用统计
    $router->post('credit/statistics', [\App\Http\Controllers\Network\CreditController::class, 'Statistics']);
    //配送费明细
    $router->post('delivery/fee/record', [\App\Http\Controllers\Network\StatisticsController::class, 'DeliveryFeeRecord']);
    //网点空桶明细
    $router->post('barrel/deposit/record', [\App\Http\Controllers\Network\StatisticsController::class, 'BarrelDepositRecord']);
    //上货订单列表
    $router->post('loading/order/listing', [\App\Http\Controllers\Network\LoadingOrderController::class, 'OrderListing']);
    //删除订单
    $router->any('loading/order/delete', [\App\Http\Controllers\Network\LoadingOrderController::class, 'OrderDelete']);
    //取消订单
    $router->post('loading/order/cancel', [\App\Http\Controllers\Network\LoadingOrderController::class, 'OrderCancel']);
    //网点还桶
    $router->post('loading/return/bucket', [\App\Http\Controllers\Network\LoadingOrderController::class, 'ReturnBucket']);
    //统计-详情
    $router->post('statistics/detail', [\App\Http\Controllers\Network\StatisticsController::class, 'Detail']);
    //统计-列表
    $router->post('statistics/listing', [\App\Http\Controllers\Network\StatisticsController::class, 'Listing']);
    //子账号管理-新增
    $router->post('account/add', [\App\Http\Controllers\Network\AccountController::class, 'Add']);
    //子账号管理-编辑
    $router->post('account/edit', [\App\Http\Controllers\Network\AccountController::class, 'Edit']);
    //子账号管理-删除
    $router->post('account/delete', [\App\Http\Controllers\Network\AccountController::class, 'delete']);
    //子账号管理-列表
    $router->post('account/listing', [\App\Http\Controllers\Network\AccountController::class, 'Listing']);
    //绑定微信公众平台
    $router->post('wechat/binding', [\App\Http\Controllers\Network\AccountController::class, 'wechatBinding']);
    //微信授权
    $router->any('wechat/binding/view', [\App\Http\Controllers\Network\AccountController::class, 'wechatBindingView']);
    //微信授权回调
    $router->any('wechat/oauth/callback', [\App\Http\Controllers\Network\AccountController::class, 'wechatOauthCallback']);
});

/****************************************************************定时任务******************************************************************/
Route::group([ 'prefix' => 'crontab'], function ($router) {
    //优惠券超时
    $router->any('coupon/timeout', [\App\Http\Controllers\Crontab\CrontabController::class, 'CouponTimeout']);
    //订单完成
    $router->any('order/timeout', [\App\Http\Controllers\Crontab\CrontabController::class, 'OrderTimeout']);
    //商家月度统计
    $router->any('network/timeout', [\App\Http\Controllers\Crontab\CrontabController::class, 'NetworkTimeout']);
    //商家订单取消
    $router->any('order/cancel', [\App\Http\Controllers\Crontab\CrontabController::class, 'OrderCancel']);
});

/****************************************************************公众号******************************************************************/

Route::group([ 'prefix' => 'wechat'], function ($router) {
    //公众号配置
    $router->any('dispose', [\App\Http\Controllers\WeChat\WeChatController::class, 'dispose']);
    //推送
    $router->any('push', [\App\Http\Controllers\WeChat\WeChatController::class, 'push']);
});








